|
RSS
Feed

Wires No More!

$159.99 a pair
Wireless Serial Adapter
(Bluetooth to RS232)

$19.99
Bluetooth USB Dongle
(Class 1, EDR, v2.0)
|
Improve
compatibility between COMM-DRV's internal message loop and MFC Window
messaging and buttons.
[All versions] |
The secondary message loop used in COMM-DRV/Lib is
Win32 specific. Improved integration with MFC can be accomplished by
doing the following.
- After opening the serial port, use
CdrvSetTimeOutFunction() to setup a callback on all COMM-DRV/Lib
callbacks.
//Forward definition of function to prevent
undeclared identifier error int TimeoutFunction(int Port);
//Set timeout function that will cause prompt aborting of functions
CdrvSetTimeoutFunction(m_Port,TimeoutFunction);
//Prevent COMM-DRV/Lib's PeekMessage loop from being called. It will
be done in //the TimeoutFunction() to be MFC compliant. SetSpecialBehavior(m_Port,SB_DoNotCall2ndMsgLoop,CDRV_TRUE,0);
- Setup the callback function to handle
MFC message handling.
//**************************************************************************** //*=====TimeoutFunction() //*When installed by
CdrvSetTimeoutFunction(), this function will //*be
called periodically whenever any COMM-DRV/Lib function is //*block (waiting
for data or waiting to send data). This function //*returns 0 if it wants to
effect a timeout on the function that is //*blocked or 1 to do nothing.
//* //*A PeekMessage is added below to supercede the PeekMessage
//*loop
built into COMM-DRV/Lib since this method below is what //*Microsoft recommends
for an MFC PeekMessage loop. Note that //*the COMM-DRV/Lib PeekMessage loop
should be disabled with //*SetSpecialBehavior(m_Port,SB_DoNotCall2ndMsgLoop, //*CDRV_TRUE,0). //**************************************************************************** int TimeoutFunction(int Port) { CForcedAbortDlg *p = (CForcedAbortDlg *)CdrvGetContext(Port,0);
MSG msg; ::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE); if (!AfxGetThread()->PumpMessage())
::PostQuitMessage(0);
// let MFC do its idle processing LONG lIdle = 0; while (AfxGetApp()->OnIdle(lIdle++));
return(1); } //****************************************************************************
|
Updated:
08/14/2011 |